<?php
    session_start();
    require_once '../includes/runtime/lib/Propel.php';
    Propel::init("../includes/build/conf/easylib-conf.php");
    set_include_path("../includes/build/classes" . PATH_SEPARATOR . get_include_path());
    if(isset($_SESSION["admin_login"])&&isset($_SESSION["admin_key"])){
        $query = TabAdminQuery::create()->filterByLogin($_SESSION["admin_login"])->findOne();
        if($query!=null){
            if(md5($query->getPass())==$_SESSION["admin_key"]){
                switch ($_GET["action"]){
                    case "liste":
                        $abonnes = TabAbonneQuery::create()->find();
                        echo $abonnes->toJSON();
                        break;
                    case "modifier":
                        $abonne = TabAbonneQuery::create()->filterByIdAbonne($_GET["id"])->findOne();
                        $abonne->setNom(stripslashes($_GET["nom"]));
                        $abonne->setPrenom(stripslashes($_GET["prenom"]));
                        $abonne->setEmail(stripslashes($_GET["email"]));
                        $abonne->setAdresse(stripslashes($_GET["adresse"]));
                        $abonne->save();
                        break;
                }
            }
        }
    }
?>
